package common.impl;

import java.util.Random;

public class CreateRandomCode {
	private static final String[] randomString=new String[]{"0","1","2","3","4","5","6","7","8","9","a","b","c",
	                               "d","e","f","g","h","i","j","k","m","n","p","q","r",
	                               "s","t","u","v","w","x","y","z"};
	private static final int randomLength=36;
	
	private static final String[] randomNumString=new String[]{"0","1","2","3","4","5","6","7","8","9"};
	private static final int randomNumLength=10;
	
	public static String getRandomString(int length){
		if(length <=0)
			return null;
		Random rand = new Random();
		String r = "";
		for(int i=0;i<length;i++){
			r += randomString[Math.abs(rand.nextInt() % randomLength)];
		}
		return r;
	}
	
	public static String getRandomNumString(int length){
		if(length <=0)
			return null;
		Random rand = new Random();
		String r = "";
		for(int i=0;i<length;i++){
			r += randomNumString[Math.abs(rand.nextInt() % randomNumLength)];
		}
		return r;
	}
}
